---
category: Validator
created: '2020-05-03'
title: Validate a Gregorian date
updated: '2021-10-13'
---

**JavaScript version**

```js
// `m`: the month (zero-based index)
// `d`: the day
// `y`: the year
const isValidDate = (m, d, y) => 0 <= m && m <= 11 && 0 < y && y < 32768 && 0 < d && d <= new Date(y, m, 0).getDate();
```

**TypeScript version**

```ts isValidDate.ts
const isValidDate = (m: number, d: number, y: number): boolean =>
    0 <= m && m <= 11 && 0 < y && y < 32768 && 0 < d && d <= new Date(y, m, 0).getDate();
```
